package fun.barryhome.ebean;


import fun.barryhome.ebean.model.Customer;
import fun.barryhome.ebean.model.SomeEmbedd;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.time.LocalDate;
import java.util.*;

/**
 * Created on 2020/9/8 11:45 上午
 *
 * @author barry
 * Description:
 */
@SpringBootApplication
public class EBeanApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(EBeanApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        List<UUID> uids = new ArrayList<>();
        uids.add(UUID.randomUUID());
        uids.add(UUID.randomUUID());

        Map<String, SomeEmbedd> map = new HashMap<>();
        map.put("abc", SomeEmbedd.builder().one("1").two("2").three("3").build());
        map.put("def", SomeEmbedd.builder().one("4").two("5").three("6").build());

        Customer customer = Customer.builder()
                .name("hy222")
                .phone("13812345678")
                .registered(LocalDate.now())
                .uids(uids)
                .some(SomeEmbedd.builder().one("1").two("2").three("3").build())
                .loginCount(1)
                .status(Customer.Status.COMPLETE)
                .map(map)
                .build();
        customer.save();

    }
}
